package com.imooc.dataobject;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.imooc.enums.ProductStatusEnum;
import com.imooc.utils.EnumUtils;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 功能描述: <br>
 * (商品信息实体类)
 *
 * @Author:Mr. xyb
 * @Date: 2018/5/18 17:36
 * @since: 1.8.0
 * @version: 1.0.0
 */
@Entity
@Data
@DynamicUpdate
public class ProductInfo {
    @Id
    private String productId;

    /*名字*/
    private String productName;

    /*单价*/
    private BigDecimal productPrice;

    /*库存*/
    private Integer productStock;

    /*描述*/
    private String productDescription;

    /*小图*/
    private String productIcon;

    /*状态0正常1下架*/
    private Integer productStatus = ProductStatusEnum.UP.getCode();

    /*类目编号*/
    private Integer categoryType;

    private Date createTime;

    private Date updateTime;

    /*商品状态名称*/
    @JsonIgnore
    public ProductStatusEnum getProductStatusEnum() {
        return EnumUtils.getCode(productStatus, ProductStatusEnum.class);
    }

}